package com.ds.infrastructure.hyperspace.container.flow.listener;

import com.ds.infrastructure.hyperspace.common.EndpointNode;
import com.ds.infrastructure.hyperspace.common.flow.DuplexFlowContext;

/**
 * @author  Weishaoying
 */
public interface HyperspaceEventListener<C extends DuplexFlowContext> {

    /**
     * Fire input data
     * @param duplexFlowContext
     * @param data
     */
    void fireEntryInput(C duplexFlowContext, Object data);

    /**
     * Fire no more input for this request at entry
     * @param duplexFlowContext
     */
    void fireEntryInputComplete(C duplexFlowContext);

    /**
     * Fire target input data
     * @param duplexFlowContext
     * @param data
     */
    void fireTargetInput(C duplexFlowContext, Object data);

    /**
     * Fire no more input for this request at target
     * @param duplexFlowContext
     */
    void fireTargetInputComplete(C duplexFlowContext);

    /**
     * Fire out put data
     * @param duplexFlowContext
     * @param data
     */
    void fireEntryOutput(C duplexFlowContext, Object data);

    /**
     * Fire out put data complete
     * @param duplexFlowContext
     */
    void fireEntryOutputComplete(C duplexFlowContext);

    /**
     * Fire out put data
     * @param duplexFlowContext
     * @param data
     */
    void fireTargetOutput(C duplexFlowContext, Object data);

    /**
     * Fire out put data complete
     * @param duplexFlowContext
     */
    void fireTargetOutputComplete(C duplexFlowContext);

    /**
     * Fire entry channel active
     * @param endpointNamespace
     */
    void fireEntryChannelActive(String endpointNamespace);

    /**
     * Fire entry channel inactive
     * @param endpointNamespace
     */
    void fireEntryChannelInactive(String endpointNamespace);

    /**
     * Fire target channel active
     * @param endpointNode
     */
    void fireTargetChannelActive(EndpointNode endpointNode);

    /**
     * Fire target channel inactive
     * @param endpointNode
     */
    void fireTargetChannelInactive(EndpointNode endpointNode);

    /**
     * Fire entry occur exception
     * @param duplexFlowContext
     * @param cause
     */
    void fireEntryExceptionCaught(C duplexFlowContext, Throwable cause);

    /**
     * Fire target occur exception
     * @param endpointNamespace
     * @param cause
     */
    void fireTargetExceptionCaught(String endpointNamespace, Throwable cause);

    /**
     * Fire pending request increment
     * @param endpointNamespace
     */
    void firePendingRequestIncrement(String endpointNamespace);

    /**
     * Fire pending requests decrement
     * @param endpointNamespace
     */
    void firePendingRequestDecrement(String endpointNamespace);

    /**
     * Fire while node status changed
     * @param endpointNamespace
     * @param nodeInfo
     * @param status
     */
    void fireTargetNodeStatusChange(String endpointNamespace, String nodeInfo, int status);

}
